<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<form action="#">
		<input type="text" id="username">
		<input type="button" id="btn" value="提交">
	</form>
	<script>
		var btn = document.getElementById('btn')
		btn.addEventListener('click', function () {
			var form  = document.forms[0]
			form.submit()
			console.log("表单被提交");
			
		})
	</script>
</body>

</html>